package uit.server.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class DataSet implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	private  List<Row> rows =new ArrayList<Row>();
	private  List<String> headers =new ArrayList<String>();
	
	public void addRow(int idx , String  fieldName , String value){
		Row row = new Row();
		row.setFieldName(fieldName);
		row.setValue(value);
		headers.add(idx , fieldName);
		rows.add(idx, row);
	}
	
	public void addRow(int idx , String value){
		Row row = new Row();
		row.setValue(value);
		rows.add(idx, row);
	}
	
	public Row getRow(int idx){
		return rows.get(idx);
	}
	
}

class Row{
	private String  fieldName;
	private String  value;
	
	public String getFieldName() {
		return fieldName;
	}
	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Row other = (Row) obj;
		if (fieldName == null) {
			if (other.fieldName != null)
				return false;
		} else if (!fieldName.equals(other.fieldName))
			return false;
		if (value == null) {
			if (other.value != null)
				return false;
		} else if (!value.equals(other.value))
			return false;
		return true;
	}
	
}
